/*
 * CRecordTest.java
 * JMUnit based test
 *
 * Created on 24.03.2011, 19:44:41
 */

package Model;



import jmunit.framework.cldc10.*;

import java.util.Date;

/**
 * @author Pisarchik_S
 */
public class CRecordTest extends TestCase {
    
    public CRecordTest() {
        //The first parameter of inherited constructor is the number of test cases
        super(1,"CRecordTest");
    }            

    public void test(int testNumber) throws Throwable {
        switch (testNumber) {
            case 0:
                testSaveLoad();
                break;
            default:
                break;
        }
    }

    /**
     * Test of testGetBytes method, of class CRecord.
     */
    public void testSaveLoad() throws AssertionFailedException {
        System.out.println("getBytes");
        CCategory [] categories = new CCategory[10];
        for (int i = 0; i < 10; ++i)
            categories[i] = new CCategory();
        CCurrency [] curencies = new CCurrency[10];
        for (int i = 0; i < 10; ++i)
            curencies[i] = new CCurrency();

        Date d = new Date();
        CRecord instance = new CRecord(curencies[5], d, categories[2], 100500);
        instance.m_Notes = new String("Прывітанне ўсім хто мяне ведае");
        CRecord instance2 = new CRecord(null, null, null, 0);
        byte [] b = instance.getBytes(categories, curencies);
        instance2.fromBytes(b, categories, curencies);

        assertEquals("Катэгорыя",instance.m_category, instance2.m_category);
        assertEquals("Валюта",instance.m_currency, instance2.m_currency);
        assertEquals("Час",instance.m_date.getTime(), instance2.m_date.getTime());
        assertEquals("Грошы",instance.m_nAmount, instance2.m_nAmount);
        assertEquals("Заметкі не захаваліся",instance.m_Notes, instance2.m_Notes);
    }

}
